package com.lamda.zhekou.master.session;

import io.netty.channel.Channel;

import java.sql.Timestamp;

/**
 * Created by MJiao on 15/8/25.
 */
public class WorkerSession {

    private String uuid;


    private Channel channel;

    private String workerIp;

    /**
     * session的创建时间
     */
    private Timestamp createTime;

    public WorkerSession() {
        this.createTime = new Timestamp(System.currentTimeMillis());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof WorkerSession)) return false;

        WorkerSession that = (WorkerSession) o;

        return !(getWorkerIp() != null ? !getWorkerIp().equals(that.getWorkerIp()) : that.getWorkerIp() != null);

    }

    @Override
    public int hashCode() {
        return getWorkerIp() != null ? getWorkerIp().hashCode() : 0;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public Channel getChannel() {
        return channel;
    }

    public void setChannel(Channel channel) {
        this.channel = channel;
    }

    public String getWorkerIp() {
        return workerIp;
    }

    public void setWorkerIp(String workerIp) {
        this.workerIp = workerIp;
    }

    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "WorkerSession{" +
                "uuid='" + uuid + '\'' +
                ", channel=" + channel +
                ", workerIp='" + workerIp + '\'' +
                ", createTime=" + createTime +
                '}';
    }
}
